﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

namespace DaoYou.Web.Controller
{
    public partial class Header : System.Web.UI.UserControl
    {
        protected string LoginAccount { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie userCookie = HttpContext.Current.Request.Cookies[ConfigurationManager.AppSettings["COOKIE_KEY_USER"] as string];
            try
            {
                if (userCookie != null)
                {
                    this.LoginAccount = userCookie.Values["name"].ToString();
                }
            }
            catch
            {
            }
        }

        protected void lbtnLogout_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < Response.Cookies.Count; i++)
            {
                Response.Cookies[i].Expires = DateTime.Now; //cookie将马上过期
            }

            HttpContext.Current.Response.Cookies[ConfigurationManager.AppSettings["COOKIE_KEY_USER"].ToString()].Expires = DateTime.Now.AddDays(-1);

            Response.Redirect("~/Default.aspx");
        }
    }
}